import 'package:flutter/material.dart';
import 'package:flutter_demo/ui/pages/status/inherited/update/share_update_widget.dart';

class B1PageWidget extends StatefulWidget {
  const B1PageWidget({super.key});

  @override
  State<B1PageWidget> createState() => _B1PageWidgetState();
}

class _B1PageWidgetState extends State<B1PageWidget> {
  @override
  Widget build(BuildContext context) {
    return Material(
      child: Column(
        children: [
          Text("${ShareUpdateWidget.of(context).nickname}"),
          SizedBox(
            height: 20,
          ),
          ElevatedButton(
            onPressed: () {
              ShareUpdateWidget.of(context).nickname = "我被B改了";
              ShareUpdateWidget.update(context);
            },
            child: Text("B页面:更改nickname的值"),
          ),
          SizedBox(
            height: 20,
          ),
          ElevatedButton(
            onPressed: () {
              Navigator.of(context).pop();
            },
            child: Text("B页面:使用路由情况返回A"),
          ),
        ],
      ),
    );
  }
}
